﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using MINERP.COM;

namespace MINERP.AutoOrder_Fuji
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            //MessageBox.Show("进行加密");
            //try
            //{
            //    UDPMessage.EncryptConfiguration();
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message + ex.StackTrace + ex.TargetSite);
            //}

            //MessageBox.Show("加密成功");
            bool isAppRunning = false;
            System.Threading.Mutex mutex = new System.Threading.Mutex(
                true,
                "AutoReloveAAAA",
                out isAppRunning);

            if (!isAppRunning)
            {
                MessageBox.Show("本程序已运行，请不要重复运行！");
                Environment.Exit(1);
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Application.ApplicationExit += new EventHandler(UDPMessage.Application_ApplicationExit);

                if (UDPMessage.ProcessReceiveMsg(false))
                {
                    Application.Run(new FrmAutoMain());
                }
            }

        }
    }
}